package com.clock.mapper;


import com.clock.domain.entity.DailyRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (DailyRecord)表数据库访问层
 *
 * @author makejava
 * @since 2022-12-29 21:23:08
 */
@Mapper
public interface DailyRecordMapper {

    int insert(@Param("dailyRecord") DailyRecord dailyRecord);

    List<DailyRecord> queryRecordsByLimit(Long userId);

    @Select("select sum(study_time) from daily_record where MONTH(create_time) = MONTH(now()) " +
            "and YEAR(create_time) = YEAR(now()) and user_id = #{userId}")
    Long queryAllByStudyTimeOneMouth(Long userId);

    @Select("SELECT study_content,create_time,study_time FROM daily_record WHERE MONTH(create_time) = MONTH(now()) \n" +
            "and YEAR(create_time) = YEAR(now()) and user_id = #{userId}")
    List<DailyRecord> queryRecordsByOneMouth(Long userId);


}
